home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / date.arc / README < prev   
Internet Message Format  |  1989-05-25  |  4KB

  1. From: dal@syntel.UUCP (Dale Schumacher)
  2.  
  3. [close@cacilj.UUCP (Diane Barlow Close) writes...]
  4. > In article <3229@cs.dal.ca> silvert@cs.dal.ca (Bill Silvert) writes:
  5. >>- I asked about a bug I have run into, and they hadn't run into it --
  6. >>  have any of you?  My date function doesn't work, it always generates a
  7. >>  date on Jan. 1 some year in the 21st century (which year I forget).
  8. >>  The guy I spoke for said it works for him.  Perhaps it involves my
  9. >>  clock-setting software -- I use the clock that comes with the Supra
  10. >>  60-Meg hard drive, which seems to work fine for everything else.
  11. >>  Anyone have any idea what the problem might be?  It would be a very
  12. >>  useful function if I could get it to work!
  13. > There are actually 3 clocks in the ST.  They are the keyboard clock, the TOS
  14. > clock, and the BIOS clock.  Some hard drives set only one clock.  My BMS card
  15. > sets only the TOS clock.  If I remember correctly, I think WP uses the BIOS 
  16. > clock (a leftover from PC days, perhaps?).  Since the BMS clock only sets the 
  17. > TOS clock, my time and date in WP are screwed up (Jan 20 20??, way in the 
  18. > future).
  19.  
  20. I don't think there are really 3 clocks in the ST, only 2, but you're on
  21. the right track.  The Supra SUPCLKRD program reads the clock in the disk
  22. drive and sets the GEMDOS time accordingly.  The GEMDOS time (or system
  23. time) is reset on even a warm-boot and defaults to some time in 1985.
  24. This is the time used to time-stamp files when they are created and is
  25. the most often used time reference.  The BIOS time (or keyboard time) is
  26. maintained by the processor in the keyboard and is independent of the
  27. system clock.  It also retains it's time setting through a warm-boot, but
  28. not through a cold-boot.  On cold-boot (power off), the keyboard clock
  29. defaults to the 20xx year value described above.
  30.  
  31. > To fix this irritating problem, my husband wrote a small program in Mark 
  32. > William's C that sets the BIOS clock.  Since it's a small program, I'll 
  33. > include it here:
  34. > /*    set all clocks according to TOS time    */
  35. > #include <time.h>
  36. > #include <osbind.h>
  37. > main() {
  38. >     tetd_t td;
  39. >     td = ((long)Tgetdate()<<16) | (unsigned)Tgettime();
  40. >     Settime(td);
  41. >     Ksettime(tetd_to_tm(td));
  42. > }
  43.  
  44. There are a number of MWC specific features here, like Ksettime() and
  45. tetd_to_tm(), so I'm not certain what this is really doing, but I assume
  46. that it "does the right thing" when compiled with MWC.  From the operating
  47. system level there are a set of GEMDOS functions for reading/setting the
  48. system time, they are:
  49.  
  50. #define    Tgetdate()            (int)gemdos(0x2A)
  51. #define    Tsetdate(date)            gemdos(0x2B,date)
  52. #define    Tgettime()            (int)gemdos(0x2C)
  53. #define    Tsettime(time)            gemdos(0x2D,time)
  54.  
  55. ...and there are a couple of XBIOS functions for reading/setting the
  56. keyboard time, they are:
  57.  
  58. #define    Settime(time)            xbios(22,time)
  59. #define    Gettime()            xbios(23)
  60.  
  61. The parameters for these calls differ considerably, so you should look
  62. them up before trying to use these calls.  I expect that the problems
  63. of the original poster were due to using the XBIOS calls and thus refering
  64. to the keyboard clock, which wasn't being set properly.
  65.  
  66. ...AND NOW FOR SOMETHING COMPLETELY DIFFERENT... A BUG REPORT!
  67.  
  68. There is a nasty bug that crops up when you are working with both clocks
  69. at the same time.  If you read the system date and time, then read the
  70. keyboard time, and immediately set the system date and time, the KEYBOARD
  71. clock will stop counting and seems to set itself to an unusual value.
  72. If you read the keyboard clock first, then the system, and then set the
  73. system time, everything works just fine.
  74.  
  75. Here is a program which handles all of these problems correctly, sets
  76. both clock, works nicely from the /AUTO/ folder and is fairly intelligent
  77. about determining good defaults for the time.
  78.  
  79.